<?php

class PlayerObject extends GObject
{
	public function __construct($fields)
	{
		parent::__construct();
		
		foreach ($fields as $key => $val)
		{
			switch ($key)
			{
				case "id":
					$this->oId = $val;
					break;
				case "name":
					$this->oName = $val;
					break;
				case "password":
					$this->oHashPass = $val;
					break;
				case "raw_password":
					$this->oHashPass = hashPass($val);
					break;
				case "mail":
					$this->oMail = $val;
					break;
				case "about":
					$this->oAbout = $val;
					break;
				case "gold":
					$this->oGold = $val;
					break;
				case "ac_level":
					$this->oAcLevel = $val;
					break;
				case "register_date":
					$this->oRegisterDate = $val;
					break;
			}
		}
	}
	
	public function setId($id) { $this->oId = $id; }
	public function id() { return $this->oId; }
	
	public function setName($name) { $this->oName = $name; }
	public function name() { return $this->oName; }
	
	public function setMail($mail) { $this->oMail = $mail; }	
	public function mail() { return $this->oMail; }
	
	public function setAbout($about) { $this->oAbout = $about; }
	public function about() { return $this->oAbout; }
	
	public function setPassword($password) { $this->oHashPass = hashPass($password); }
	public function password() { return $this->oHashPass; }
	
	public function setGold($gold) { $this->oGold = $gold; }
	public function gold() { return $this->oGold; }
	
	public function setAcLevel($acLevel) { $this->oAcLevel = $acLevel; }
	public function acLevel() { return $this->oAcLevel; }
	
	public function registerDate() { return $this->oRegisterDate; }
	
	public function testPass($pass)
	{
		return ($this->oHashPass == hashPass($pass, $this->oHashPass));
	}
	
}

?>